﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for utilities
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Proxy : System.Web.Services.WebService
{

	public Proxy()
	{

		//Uncomment the following line if using designed components 
		//InitializeComponent(); 
	}

	#region Misc

	/// ToXmlDocument
	private static System.Xml.XmlDocument ToXmlDocument(
		System.Object data)
	{
		System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
		xmlDoc.LoadXml(EFS.Common.Serialization.Functions.SerializeToString(data));
		return xmlDoc;
	}

	#endregion

	#region HW
	#region Contact

	/// <summary>
	///  Getting a list of contacts
	/// </summary>
	/// <param name="firstname"></param>
	/// <param name="surname"></param>
	/// <param name="postcode"></param>
	/// <param name="customerTelNo"></param>
	/// <param name="policyReference"></param>
	/// <returns></returns>
	[System.Web.Services.WebMethod]
	public System.String HW_Contact_Search(
		System.String firstname,
		System.String surname,
		System.String postcode,
		System.String customerTelNo,
		System.String policyReference,
		System.Int32 maxRows)
	{
		try
		{
			// get array
			EFS.CC.HW.Views.BeneficiaryInfo[] beneficiaryInfoArray =
				EFS.CC.HW.Query.SearchApplicant(firstname, surname, postcode, customerTelNo, policyReference, maxRows);

			// return
			return EFS.Common.Serialization.Functions.SerializeToString(beneficiaryInfoArray);
		}
		catch (System.Exception ex)
		{
			// log
			EFS.EventLog.Log.LogException(ex, null);


			// throw again
			throw ex;
		}
	}
	#endregion
	#endregion

	#region Classification

	[System.Web.Services.WebMethod]
	public System.String Classifications_GetByLineId(System.Int32 lineId)
	{
		try
		{
			// get classifications
			EFS.RC.CC.CH.Entities.Classification[] classifications = EFS.RC.CC.CH.Tables.Classifications.GetByLineId(lineId);

			// return
			return EFS.Common.Serialization.Functions.SerializeToString(classifications);	
		}
		catch (System.Exception ex)
		{
			// log
			EFS.EventLog.Log.LogException(ex, null);

			// throw again
			throw ex;
		}
	}

	#endregion

	#region HuntGroups

	    [System.Web.Services.WebMethod]
	public System.Xml.XmlDocument HuntGroups_GetAll()
	{
 		try
		{
			EFS.RC.CC.CH.Entities.HuntGroup[] huntgroupMsg = EFS.RC.CC.CH.Tables.HuntGroups.GetByAll();
			return ToXmlDocument(huntgroupMsg);
		}
		catch (System.Exception ex)
		{
			EFS.EventLog.Log.LogException(ex, null);
			throw ex;
		}
	} 

	#endregion
}
